<?php

class Transaction extends Generic_Record {
    public static function initialize($client,$db) {
        parent::initialize($db,'transaction');
    }
    
    public static function create($values) {
        $transaction = parent::create($values);
        Account_Aggregate::update(null,$transaction->row);
        return $transaction;
    }
    
    public static function delete_by_id($id) {
        $transaction = static::load_by_id($id);
        parent::delete_by_id($id);
        Account_Aggregate::update($transaction->row,null);
    }
    
    public function update($values) {
        $old = clone $this->row;
        $is_modified = parent::update($values)
        if ($is_modified)
            Account_Aggregate::update($old,$this->row);
        return $is_modified;
    }
    
    public static get_transactions($where = 1) {
        $table = static::$table;
        return $table->fetch_rows($where);
    }
    
}    
    
?>